//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package org.activiti.engine.impl.persistence.entity.data.impl;

import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.activiti.engine.impl.persistence.CachedEntityMatcher;
import org.activiti.engine.impl.persistence.entity.VariableInstanceEntity;
import org.activiti.engine.impl.persistence.entity.VariableInstanceEntityImpl;
import org.activiti.engine.impl.persistence.entity.data.AbstractDataManager;
import org.activiti.engine.impl.persistence.entity.data.VariableInstanceDataManager;
import org.activiti.engine.impl.persistence.entity.data.impl.cachematcher.VariableByExecutionIdMatcher;

public class MybatisVariableInstanceDataManager extends AbstractDataManager<VariableInstanceEntity> implements VariableInstanceDataManager {
  protected CachedEntityMatcher<VariableInstanceEntity> variableInstanceEntity = new VariableByExecutionIdMatcher();

  public MybatisVariableInstanceDataManager(ProcessEngineConfigurationImpl processEngineConfiguration) {
    super(processEngineConfiguration);
  }

  public Class<? extends VariableInstanceEntity> getManagedEntityClass() {
    return VariableInstanceEntityImpl.class;
  }

  public VariableInstanceEntity create() {
    VariableInstanceEntityImpl variableInstanceEntity = new VariableInstanceEntityImpl();
    variableInstanceEntity.setRevision(0);
    return variableInstanceEntity;
  }

  public List<VariableInstanceEntity> findVariableInstancesByTaskId(String taskId) {
    return this.getDbSqlSession().selectList("selectVariablesByTaskId", taskId);
  }

  public List<VariableInstanceEntity> findVariableInstancesByTaskIds(Set<String> taskIds) {
    return this.getDbSqlSession().selectList("selectVariablesByTaskIds", taskIds);
  }

  public List<VariableInstanceEntity> findVariableInstancesByExecutionId(String executionId) {
    return this.getList("selectVariablesByExecutionId", executionId, this.variableInstanceEntity, true);
  }

  public List<VariableInstanceEntity> findVariableInstancesByExecutionIds(Set<String> executionIds) {
    return this.getDbSqlSession().selectList("selectVariablesByExecutionIds", executionIds);
  }

  public VariableInstanceEntity findVariableInstanceByExecutionAndName(String executionId, String variableName) {
    Map<String, String> params = new HashMap(2);
    params.put("executionId", executionId);
    params.put("name", variableName);
    return (VariableInstanceEntity)this.getDbSqlSession().selectOne("selectVariableInstanceByExecutionAndName", params);
  }

  public List<VariableInstanceEntity> findVariableInstancesByExecutionAndNames(String executionId, Collection<String> names) {
    Map<String, Object> params = new HashMap(2);
    params.put("executionId", executionId);
    params.put("names", names);
    return this.getDbSqlSession().selectList("selectVariableInstancesByExecutionAndNames", params);
  }

  public VariableInstanceEntity findVariableInstanceByTaskAndName(String taskId, String variableName) {
    Map<String, String> params = new HashMap(2);
    params.put("taskId", taskId);
    params.put("name", variableName);
    return (VariableInstanceEntity)this.getDbSqlSession().selectOne("selectVariableInstanceByTaskAndName", params);
  }

  public List<VariableInstanceEntity> findVariableInstancesByTaskAndNames(String taskId, Collection<String> names) {
    Map<String, Object> params = new HashMap(2);
    params.put("taskId", taskId);
    params.put("names", names);
    return this.getDbSqlSession().selectList("selectVariableInstancesByTaskAndNames", params);
  }
}
